<template>
  <div class="rollContainer">
    <div class="searchHead" ref="searchHead">
      <div class="tableBtnBox"></div>
    </div>
    <Table :columns="columns1" :height="tableHeight" border :data="list" :loading="loading">
      <template slot-scope="{ row }" slot="time">
        <span>{{row.time|dateformat('YYYY-MM-DD HH:mm:ss')}}</span>
      </template>
    </Table>
    <div class="pageBox">
      <Page
        :total="total"
        :page-size="pageSize"
        :current="page"
        size="small"
        show-total
        show-sizer
        @on-change="changePage"
        @on-page-size-change="changeSize"
      />
    </div>
  </div>
</template>
<script>
import { userLog } from "../../api/log";
import wangEditor from "@/components/wangEditor.vue";
import upload from "@/components/upload.vue";
export default {
  components: {
    wangEditor,
    upload
  },
  data() {
    return {
      list: [],
      mices: [], //展会列表
      page: 1,
      pageSize: 20,
      total: 0,
      loading: false,
      conditions: {
        categoryId: "",
        by: ""
      },
      columns1: [
        {
          title: "id",
          key: "id",
          align: "center",
          minWidth: 60
        },
        {
          title: "ip",
          key: "ip",
          align: "center",
          minWidth: 200
        },
        {
          title: "time",
          slot: "time",
          align: "center",
          minWidth: 200
        },
        {
          title: "content",
          key: "content",
          align: "center",
          minWidth: 300
        }
      ],
      tableHeight: 100,
      miceId: "" //展会id
    };
  },
  created() {
    this.getLog();
  },
  mounted() {
    this.$nextTick(() => {
      this.tableHeight =
        window.innerHeight - this.$refs.searchHead.offsetHeight - 220;
    });
  },
  methods: {
    getLog() {
      this.loading = true;
      const { page, pageSize } = this;
      userLog({ page: page - 1, pageSize }).then(res => {
        if (res.status) {
          this.total = res.data.count;
          this.list = res.data.list;
          this.loading = false;
        } else {
          this.$Message.error(res.msg);
          this.loading = false;
        }
      });
    },
    changePage(e) {
      this.page = e;
      this.getLog();
    },
    changeSize(e) {
      this.page = 1;
      this.pageSize = e;
      this.getLog();
    }
  }
};
</script>
<style lang="less" scoped>
.page {
  display: flex;
  justify-content: flex-end;
  padding: 20px 0;
}
</style>
